package math

import "jvmgo/ch09/instructions/base"
import "jvmgo/ch09/rtda"

// double相乘指令
type DMUL struct {
    base.NoOperandsInstruction
}

func (self *DMUL) Execute(frame *rtda.Frame) {
    stack := frame.OperandStack()
    v2 := stack.PopDouble()
    v1 := stack.PopDouble()
    result := v1 * v2
    stack.PushDouble(result)
}

// float相乘指令
type FMUL struct {
    base.NoOperandsInstruction
}

func (self *FMUL) Execute(frame *rtda.Frame) {
    stack := frame.OperandStack()
    v2 := stack.PopFloat()
    v1 := stack.PopFloat()
    result := v1 * v2
    stack.PushFloat(result)
}

// int相乘指令
type IMUL struct {
    base.NoOperandsInstruction
}

func (self *IMUL) Execute(frame *rtda.Frame) {
    stack := frame.OperandStack()
    v2 := stack.PopInt()
    v1 := stack.PopInt()
    result := v1 * v2
    stack.PushInt(result)
}

// long相乘指令
type LMUL struct {
    base.NoOperandsInstruction
}

func (self *LMUL) Execute(frame *rtda.Frame) {
    stack := frame.OperandStack()
    v2 := stack.PopLong()
    v1 := stack.PopLong()
    result := v1 * v2
    stack.PushLong(result)
}
